import { createUser, findUser, updateUser, deleteUser, createOrUpdateIssuedInfo, findIssuedInfo, updateBaseInfo, findIssuedBoolean } from '@/api/userManager'

const userManager = {
    actions: {
        // 创建用户
        CreateUser({ commit }, data) {
            return new Promise((resolve, reject) => {
                createUser(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //搜索用户
        FindUser({ commit }, data) {
            return new Promise((resolve, reject) => {
                findUser(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        // 修改用户
        UpdateUser({ commit }, data) {
            return new Promise((resolve, reject) => {
                updateUser(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        // 删除用户
        DeleteUser({ commit }, data) {
            return new Promise((resolve, reject) => {
                deleteUser(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //创建或修改发布信息
        CreateOrUpdateIssuedInfo({ commit }, data) {
            return new Promise((resolve, reject) => {
                createOrUpdateIssuedInfo(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //查询发布者信息
        FindIssuedInfo() {
            return new Promise((resolve, reject) => {
                findIssuedInfo().then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //修改基本信息
        UpdateBaseInfo({ commit }, data) {
            return new Promise((resolve, reject) => {
                updateBaseInfo(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },

        //是否完善发布者信息
        FindIssuedBoolean({ commit }) {
            return new Promise((resolve, reject) => {
                findIssuedBoolean().then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        }
    }
}

export default userManager
